package org.wyq.myweb.jmx.service.imple;



import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.wyq.myweb.jmx.beaninfo.ClassLoaderInfoBean;
import org.wyq.myweb.jmx.beaninfo.IInfoBean;
import org.wyq.myweb.jmx.service.IMXBeanService;


@Service("classloadermx")
@Lazy(true)
public class DefaultClassLoaderMBeanService implements IMXBeanService{
	
	ClassLoadingMXBean classloadingMXBean = ManagementFactory.getClassLoadingMXBean();

	@Override
	public <T extends IInfoBean> T getInfoBean() {
		ClassLoaderInfoBean infoBean = new ClassLoaderInfoBean();
		infoBean.setObjectName(classloadingMXBean.getObjectName());
		infoBean.setTotalLoadedClassCount(classloadingMXBean.getTotalLoadedClassCount());
		infoBean.setLoadedClassCount(classloadingMXBean.getLoadedClassCount());
		infoBean.setUnloadedClassCount(classloadingMXBean.getUnloadedClassCount());
		return (T)infoBean;
	}

}
